<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id="show"></div>
		<hr style="width:100%; clear:left;"/>
		<input name="a" value="b&c=d"/><button>发送get</button><button>发送post</button>
		<script type="text/javascript">
			var show = document.body.firstElementChild;
			var btns = document.body.querySelectorAll("button");
			var a = document.querySelector("input");

			// btns[0].addEventListener("click",function(){
			// 	let xhr = new XMLHttpRequest();
			// 	xhr.onreadystatechange=function(){
			// 		console.info(xhr.readyState+":"+xhr.status);
			// 		if(xhr.readyState==4&&xhr.status==200){
			// 			console.info(xhr.responseText);
			// 			show.innerHTML += xhr.responseText;
			// 		}
				
			// 	}
				
			// 	xhr.open("get","inc.jsp?a="+encodeURIComponent(a.value),true);
			// 	xhr.send();
			// });
			
			btns[1].addEventListener("click",function(){
				let xhr = new XMLHttpRequest();
				xhr.onreadystatechange=function(){
					console.info(xhr.readyState+":"+xhr.status);
					if(xhr.readyState==4&&xhr.status==200){
						console.info(xhr.responseText);
						show.innerHTML += xhr.responseText;
					}
				
				}
				xhr.open("post","inc.jsp",true);
				xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				xhr.send("a="+encodeURIComponent(a.value));
			});
			
		</script>
		<form action="inc.jsp" method="post" enctype="application/x-www-form-urlencoded">
			<input name="a" value="b&c=d"/><button>发送post</button>
		</form>
</body>
</html>